﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CreateTableControlScript : System.Web.UI.Page
{
    string Script_Text = "<asp:{0} ID=\"{1}\" runat=\"server\"></asp:{0}>";
    
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        uxResult.Text = "";
        foreach (GridViewRow gr in GridView1.Rows)
        {
            if (gr.RowType == DataControlRowType.DataRow)
            {
                string colName = gr.Cells[0].Text;
                CheckBoxList createItem = (CheckBoxList)gr.FindControl("uxCreateItem");
                RadioButtonList createControlType = (RadioButtonList)gr.FindControl("uxCreateControlType");
                if (createItem.Items[0].Selected)
                {
                    uxResult.Text += string.Format(Script_Text, "Label", string.Format(uxTitleIDFormate.Text, colName));
                }

                if (createItem.Items[1].Selected)
                {
                    string ctlID = string.Format(uxControlIDFormate.Text, colName);
                    switch (createControlType.SelectedValue)
                    {
                        case "TextBox":
                            uxResult.Text += string.Format(Script_Text, "TextBox", ctlID);
                            break;
                        case "Radio":
                            uxResult.Text += string.Format(Script_Text, "RadioButtonList", ctlID);
                            break;
                        case "Check":
                            uxResult.Text += string.Format(Script_Text, "CheckBoxList", ctlID);
                            break;
                        case "DropDownList":
                            uxResult.Text += string.Format(Script_Text, "DropDownList", ctlID);
                            break;
                        default:
                            break;
                    }
                }

                uxResult.Text += "\n";
            }
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        SqlDataSource1.SelectParameters[0].DefaultValue = Tables1.SelectedValue;
        GridView1.DataBind();
    }
}
